<template>
    <div class='my-list'>
      <input type="checkbox" v-model="data.check" class="cka">
      <div class="text">
          <input type="text" v-model="data.text" v-if='data.isText' @keydown.enter="data.isText=false">
          <span v-else @dblclick="data.isText=true">{{data.text}}</span>
      </div> 
       <span class="remove" @click='skip'>-</span>
    </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["data", "index"],
  mounted() {},
  methods: {
    //   子传父传回删除的下标
    skip() {
      this.$emit("remove", this.index);
    }
  },
  components: {}
};
</script>

<style lang='scss'>
.my-list {
  width: 100%;
  height: 40px;
  background-color: #fff;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: space-between;
  border-radius: 5px;
  border-left: 5px solid green;
  .cka {
    width: 20px;
    height: 20px;
  }
  .remove {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 20px;
    background-color: #000;
    color: #fff;
  }
  .text {
    flex: 1;
    text-align: left;
    padding: 0 10px;
  }
}
</style>
